<script setup lang="ts">
// const props = defineProps<{
//   modelValue?: boolean,
// }>()

import { inject, ref } from 'vue';

import { message } from 'ant-design-vue';

const { selectProducts } = inject('selectProducts') as any;

console.log("selectProducts=",selectProducts.value)


const {
  queryParams,
  isSelectAll,
  getYxGoods,
  selectAllProducts,
  fangxuanselect,
  loading,
} = inject('queryParams') as any;
const { pageInfo } = inject('pageInfo') as any;
const showAddBox = ref(false);


function handleClick() {
  if (selectProducts.value.length === 0) {
    message.error('请选择商品');
    return;
  }
  showAddBox.value = true;
}
function onChangePagin() {
  getYxGoods && getYxGoods();
}
function selectInPageAllData() {
  selectAllProducts && selectAllProducts();
}
function fauna() {
  fangxuanselect && fangxuanselect();
}
function clearSelect() {
  selectProducts.value = [];
}
</script>

<template>
  <div
    class="bg-sidebar fixed inset-x-0 bottom-0 grid h-16 justify-items-end pr-20"
  >
    <a-space align="center">
      <a-button :loading="loading" type="primary" @click="clearSelect">
        取消选择
      </a-button>
      <a-button :loading="loading" type="primary" @click="selectInPageAllData">
        {{ isSelectAll ? '取消全选当前页' : '全选当前页' }}
      </a-button>
      <a-button :loading="loading" type="primary" @click="fauna">反选</a-button>
      <!-- <a-button
        :loading="loading"
        type="primary"
        v-bindshop
        @click="handleClick"
      >
        批量铺货({{ selectProducts.length }})
      </a-button> -->
      <a-button
        :loading="loading"
        type="primary"
        v-bindshop
        @click="handleClick"
      >
        极速铺货({{ selectProducts.length }})
      </a-button>
      <a-pagination
        v-model:current="queryParams.pageNum"
        v-model:page-size="queryParams.pageSize"
        :loading="loading"
        :page-size-options="['10', '20', '30', '40', '50']"
        :show-total="(total: any) => `共 ${total} 条`"
        :total="pageInfo.totalRecords"
        show-quick-jumper
        @change="onChangePagin"
      />
    </a-space>
    <set-add-product-box
      v-if="showAddBox"
      v-model="showAddBox"
      :select-item-list="selectProducts"
    />
  </div>
</template>
